package com.bfly.mall.product.dto;

import com.bfly.mall.product.enums.PricingMethodEnum;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 运价模板列表DTO
 *
 * @author 长沙商脉科技有限公司
 * @date 2020/9/15 21:02
 */
public class FreightTemplateListDTO implements Serializable {

    private static final long serialVersionUID = 5114574948479042179L;
    private int id;
    private String name;
    private boolean freeShipping;
    private int pricingMethod;
    private boolean freeConditions;
    private Date createDate;
    private List<FreightTemplatePricingListDTO> pricings;
    private List<FreightFreeConditionListDTO> conditions;

    public String getPricingMethodName() {
        PricingMethodEnum type = PricingMethodEnum.getPricingMethod(getPricingMethod());
        return type == null ? "" : type.getName();
    }

    public String getUnit() {
        PricingMethodEnum methodEnum = PricingMethodEnum.getPricingMethod(getPricingMethod());
        if(methodEnum!=null) {
            switch (methodEnum) {
                case PIECE:
                    return "件";
                case MONEY:
                    return "元";
                case WEIGHT:
                    return "KG";
                case VOLUME:
                    return "m³";
                default:
                    return "";
            }
        }
        return "";
    }

    public List<FreightFreeConditionListDTO> getConditions() {
        return conditions;
    }

    public void setConditions(List<FreightFreeConditionListDTO> conditions) {
        this.conditions = conditions;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isFreeShipping() {
        return freeShipping;
    }

    public void setFreeShipping(boolean freeShipping) {
        this.freeShipping = freeShipping;
    }

    public int getPricingMethod() {
        return pricingMethod;
    }

    public void setPricingMethod(int pricingMethod) {
        this.pricingMethod = pricingMethod;
    }

    public boolean isFreeConditions() {
        return freeConditions;
    }

    public void setFreeConditions(boolean freeConditions) {
        this.freeConditions = freeConditions;
    }

    public List<FreightTemplatePricingListDTO> getPricings() {
        return pricings;
    }

    public void setPricings(List<FreightTemplatePricingListDTO> pricings) {
        this.pricings = pricings;
    }
}
